<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>canvas</title>
	<style>
	#can {
		border:1px solid #ccc;
	}
	#div {
		display: inline-block;
		width:300px;
		height:200px;
		border:2px dashed #000;
	}
	</style>
</head>
<body>
	<canvas id="can">
		
	</canvas>
	<div id="div"></div>
	<script>

		function drawCanvas() {

			// 获取到canvas的元素,context是上下文
			var canvas = document.getElementById('can'),
				context = canvas.getContext('2d');

			//使用绝对坐标创建一条路径
			context.beginPath();
			context.moveTo(70,140);
			context.lineTo(140,70);

			// 将这条线绘制到canvas上
			context.stroke();
		}

		window.addEventListener('load', drawCanvas, true);
	</script>
</body>
</html>